package com.ssl.springframework.beans.factory.support;

import com.ssl.springframework.beans.factory.config.SignletonBeanRegistry;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 描述：负责存放单例Bean实例对象
 *
 * @author ssl
 * @create 2021/6/11 0011.
 */
public class DefaultSignletonBeanRegistry  implements SignletonBeanRegistry {

    private Map<String, Object> signletonObjects = new ConcurrentHashMap<>(256);

    @Override
    public Object getSignleton(String beanName) {
        return signletonObjects.get(beanName);
    }

    protected void addSignleton(String beanName, Object signletonObject) {
        synchronized (signletonObjects) {
            signletonObjects.put(beanName, signletonObject);
        }
    }
}
